//
// Created by mio on 25-5-13.
//

#ifndef H264ENCODER_H
#define H264ENCODER_H

#include <QtGlobal>
#include <vector>
#include "av_common.h"
class H264Encoder;

class VideoEncoder
{
public:
    VideoEncoder();
    VideoEncoder(const VideoEncoder&) = delete;
    VideoEncoder& operator=(const VideoEncoder&) = delete;
    ~VideoEncoder();
public:
    bool Open(qint32 width,qint32 height,qint32 framerate,qint32 bitrate,qint32 format);
    void Close();
    qint32 Encode(quint8* rgba_buffer,quint32 width,quint32 height,quint32 size,std::vector<quint8>& out_frame);
    qint32 GetSequenceParams(quint8* out_buffer, qint32 out_buffer_size);
private:
    bool IsKeyFrame(AVPacketPtr pkt);
private:
    AVConfig config_;
    std::unique_ptr<H264Encoder> h264_encoder_;
};


#endif //H264ENCODER_H